import pymysql
import hashlib

class Tools:

    def __init__(self,session,hostip='114.132.200.42',hostport='3456'):
        self.hosturl = f'http://{hostip}:{hostport}'
        self.session = session

    def using_md5(self,text):
        m = hashlib.md5()  # 创建一个 md5加密工具
        m.update(str(text).encode(encoding='utf-8'))
        res = m.hexdigest()  # 生成加密后的内容
        return res

    def using_mysql(self,sql_text):
        db = pymysql.connect(
            user='mytodo',
            password='iDnjrLSKDAxdAL26',
            host='114.132.200.42',
            port=3306,
            database="mytodo",
            charset='utf8mb4')
        cs = db.cursor()
        cs.execute(str(sql_text))
        data = cs.fetchall()
        db.commit()
        db.close()
        return data







